package com.bops.dal.product.dao.impl;

import java.util.HashMap;
import java.util.List;

import com.bops.dal.product.dao.Type2DAO;
import com.bops.dal.product.dataobject.TypeTwo;
import com.bops.dal.product.queryobject.TypeTwoQuery;
import com.yue.commons.db.ibatis.YueBaseSqlMapClientDaoSupport;

public class Type2DAOImpl  extends YueBaseSqlMapClientDaoSupport implements Type2DAO {
	private static final String NAME_SPACE = "TYPE2_PRODUCT.";
	
	
	public int countType2(HashMap<String, Object> map) {
		return (Integer) getSqlMapClientTemplate().queryForObject(NAME_SPACE + "count_Type2", map);
	}
	public int checkType2Name(TypeTwo editType2 ) {
		return (Integer) getSqlMapClientTemplate().queryForObject(NAME_SPACE + "checkName",  editType2);
	}

	public int deleteType2ById(Integer id) {
		int rows = getSqlMapClientTemplate().delete(NAME_SPACE + "delete", id);
		return rows;
	}

	
	public void insertType2(TypeTwo record) {
		getSqlMapClientTemplate().update(NAME_SPACE + "insert", record);
	}

	
	public int updateType2(TypeTwo record) {
		int rows = getSqlMapClientTemplate().update(NAME_SPACE + "update", record);
		return rows;
	}

	@SuppressWarnings("unchecked")
	public List<TypeTwo> listType2(TypeTwoQuery query) {
		if (query==null)
        {
            query = new TypeTwoQuery();
            query.setPageSize(Integer.MAX_VALUE);
        }
        return getSqlMapClientTemplate().queryForPagination(NAME_SPACE + "count_Type2",
        		NAME_SPACE + "list_Type2", query);
	}
	
	@SuppressWarnings("unchecked")
	public List<TypeTwo> completeType2(TypeTwoQuery query) {
		return getSqlMapClientTemplate().queryForList(NAME_SPACE + "complete_Type2", query);
	}

	
	public TypeTwo findType2ById(Integer id) {
		return (TypeTwo)getSqlMapClientTemplate().queryForObject(NAME_SPACE + "listById", id);
	}
	public TypeTwo findType2IDByName( TypeTwoQuery queryType2) {
		return (TypeTwo)getSqlMapClientTemplate().queryForObject(NAME_SPACE + "type2IdByName", queryType2);
	}
    
}